﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BKH.BLL
{
    class LichTrucBUO:IBUO<tbl_LichTruc>
    {

        HospitalDBDataContext context = new HospitalDBDataContext();
             
        public bool Insert(tbl_LichTruc obj)
        {
            try
            {
                context.tbl_LichTrucs.InsertOnSubmit(obj);
                context.SubmitChanges();
                return true;


            }
            catch (Exception)
            {
                
                return false;
            }
        }

        public bool Delete(int id)
        {
            throw new NotImplementedException();
        }

        public bool Delete(tbl_LichTruc obj)
        {
            throw new NotImplementedException();
        }

        public List<tbl_LichTruc> GetAll()
        {
            throw new NotImplementedException();
        }

        public tbl_LichTruc GetSingle(int id)
        {
            throw new NotImplementedException();
        }

        public bool Update(int id, tbl_LichTruc obj)
        {
            throw new NotImplementedException();
        }

        public int GetMaLichTruc(int Phong, String Ngay)
        {
            var t = context.tbl_LichTrucs.Where(n => n.KhoaPhongID == Phong && n.NgayDatLich.Equals(Ngay)).ToList<tbl_LichTruc>();
            if (t.Count!=0)
            {
                return t.OrderByDescending(n => n.LichTrucID).FirstOrDefault().LichTrucID;

            }
            else
                return -1;
        }
    }
}
